package com.clz.servlet;

import com.clz.Dao.Impl.UserDaoImpl;
import com.clz.Dao.UserDao;
import com.clz.entiy.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/showUser")
public class showUserServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String uid=request.getParameter("userId");
        int userId=Integer.parseInt(uid);
        UserDao userDao=new UserDaoImpl();
        User user =userDao.selectUserById(userId);
        request.setAttribute("user", user);
        request.getRequestDispatcher("showUser.jsp").forward(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
